<?php

namespace App\Grpc;

use Grpc\CalculateRequest;
use Grpc\CalculateResponse;
use Hyperf\GrpcClient\BaseClient;

class CalculateClient extends BaseClient
{
    public function __construct()
    {
        $hostname = 'calc-srv:9523';
        $options = [
            'credentials' => null,
        ];
        parent::__construct($hostname, $options);
    }

    public function add(CalculateRequest $request) :CalculateResponse
    {
         return $this->_simpleRequest("/calc/add",$request,[CalculateResponse::class,"decode"])[0];
    }

    public function sub(CalculateRequest $request) :CalculateResponse
    {
        return $this->_simpleRequest("/calc/sub",$request,[CalculateResponse::class,"decode"])[0];
    }

    public function mul(CalculateRequest $request) :CalculateResponse
    {
        return $this->_simpleRequest("/calc/mul",$request,[CalculateResponse::class,"decode"])[0];
    }

    public function div(CalculateRequest $request) :CalculateResponse
    {
        return $this->_simpleRequest("/calc/div",$request,[CalculateResponse::class,"decode"])[0];
    }
}